# !/usr/bin python3
# encoding: utf-8 -*-
# @file     : login_page.py
# @author   : 沙陌 Matongxue_2
# @Time     : 2023/11/12 10:01
# @Copyright: 北京码同学

from pages.base_page import BuyerBasePage


class LoginPage(BuyerBasePage):
    # def __init__(self):
    #     super().__init__()
    #     self.page_eles = load_yaml_file(buyer_yaml)[self.__class__.__name__]
    def click_user_login(self):
        ele_info = self.page_eles['账号登录']
        # ele_info = {"name":"账号登录","type":"linktext","value":"账号登录","timeout":5}
        self.operate.click(ele_info)
        # 如果这个动作，没有跳转页面，则可以返回自身
        return self

    def send_keys_username(self,username):
        ele_info = self.page_eles['用户名输入框']
        # ele_info = {"name": "用户名输入框", "type": "id", "value": "username", "timeout": 5}
        self.operate.send_keys(ele_info,username)
        return self
    def send_keys_password(self,password):
        ele_info = self.page_eles['密码输入框']
        # ele_info = {"name": "密码输入框", "type": "id", "value": "password", "timeout": 5}
        self.operate.send_keys(ele_info,password)
        return self
    def send_keys_validcode(self,validcode):
        ele_info = self.page_eles['验证码输入框']
        # ele_info = {"name": "验证码输入框", "type": "id", "value": "validcode", "timeout": 5}
        self.operate.send_keys(ele_info,validcode)
        return self
    def click_login_btn(self):
        ele_info = self.page_eles['登录按钮']
        # ele_info = {"name": "登录按钮", "type": "xpath", "value": '(//button[@class="form-sub"])[2]', "timeout": 5}
        self.operate.click(ele_info)
        return self